<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="question5.css" rel="stylesheet">
    <!--下载jquery,并实现此前买游戏装备的那个案例（全选全不选）-->
</head>
<body>
<div id="body">
    <div class="head">
        <div class="d1"><input type="checkbox" id="chkAll" onclick="chkAll(this)"/>全选</div>
        <div class="d2">商品图片</div>
        <div class="d3">商品名称/出售者/联系方式</div>
        <div class="d4">价格</div>
    </div>
    <div class="head1">
        <div class="d1"><input type="checkbox" name="chk" value="1" onclick="changeChk(this)"/></div>
        <div class="d2"><img src="img/list0.jpg"></div>
        <div class="d3">
            <p>杜比环绕，家庭影院必备，超真实感受</p>
            <p>出售者：ling112233</p>
            <p><img src="img/online_pic.gif">&nbsp;&nbsp;&nbsp;<img src="img/list_tool_fav1.gif">收藏</p>
        </div>
        <div class="d4">
            <p>一口价</p>
            <p>2833.0</p>
        </div>
    </div>
    <div class="head1">
        <div class="d1"><input type="checkbox" name="chk" value="2" onclick="changeChk(this)"/></div>
        <div class="d2"><img src="img/list1.jpg"></div>
        <div class="d3">
            <p>NVDIA&nbsp;9999GT&nbsp;512MB&nbsp;256bit极品显卡，不容错过</p>
            <p>出售者：aipiaopiao110</p>
            <p><img src="img/online_pic.gif">&nbsp;&nbsp;&nbsp;<img src="img/list_tool_fav1.gif">收藏</p>
        </div>
        <div class="d4">
            <p>一口价</p>
            <p>6464.0</p>
        </div>
    </div>
    <div class="head1">
        <div class="d1"><input type="checkbox" name="chk"  value="3" onclick="changeChk(this)"/></div>
        <div class="d2"><img src="img/list2.jpg"></div>
        <div class="d3">
            <p>精品热卖，高清晰，30寸等离子电视</p>
            <p>出售者：阳光的挣扎</p>
            <p><img src="img/online_pic.gif">&nbsp;&nbsp;&nbsp;<img src="img/list_tool_fav1.gif">收藏</p>
        </div>
        <div class="d4">
            <p>一口价</p>
            <p>18888.0</p>
        </div>
    </div>
    <div class="head1">
        <div class="d1"><input type="checkbox" name="chk"  value="4" onclick="changeChk(this)"/></div>
        <div class="d2"><img src="img/list3.jpg"></div>
        <div class="d3">
            <p>Sony索尼家用最新款笔记本</p>
            <p>出售者：疯狂的镜无</p>
            <p><img src="img/online_pic.gif">&nbsp;&nbsp;&nbsp;<img src="img/list_tool_fav1.gif">收藏</p>
        </div>
        <div class="d4">
            <p>一口价</p>
            <p>5889.0</p>
        </div>
    </div>
</div>
<script src="jquery.min.js"></script>
<script type="text/javascript">
    $("#chkAll").on("click",function(){
        var flag = this.checked;
        $("input[name='chk']").each(function(){
            this.checked = flag;
        });
    });

    $("input[name='chk']").on("click",function(){
        if(this.checked){
            var flag = true;
            $("input[name='chk']").each(function(){
                if(!this.checked){
                    flag = false;
                }
            });
            $("#chkAll").get(0).checked = flag;
        }else{
            $("#chkAll").get(0).checked = false;
        }
    });

</script>
</body>
</html>